package com.small.nacos.naming.core;

import com.small.nacos.naming.misc.UtilsAndCommons;

/**
 * @Author zhoujin
 * @Date 2022/7/22 20:56
 */
public class Instance extends com.alibaba.nacos.api.naming.pojo.Instance {

    private volatile long lastBeat = System.currentTimeMillis();

    public String generateInstanceId() {
        return getIp() + "#" + getPort() + "#" + getClusterName() + "#" + getServiceName();
    }

    public String getDatumKey() {
        if (getPort() > 0) {
            return getIp() + ":" + getPort() + ":" + UtilsAndCommons.LOCALHOST_SITE + ":" + getClusterName();
        } else {
            return getIp() + ":" + UtilsAndCommons.LOCALHOST_SITE + ":" + getClusterName();
        }
    }

    public void setLastBeat(long lastBeat) {
        this.lastBeat = lastBeat;
    }
}
